﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _26_RemoveDuplicates
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = { 1, 1, 2 };

            int result = RemoveDuplicates(nums);

            Console.WriteLine(result);

            Console.ReadLine();
        }

        private static int RemoveDuplicates(int[] nums)
        {
            int result = 0;
            if (nums.Length > 1)
            {
                for (int i = 0; i < nums.Length - 1; i++)
                {
                    if (nums[i] != nums[i + 1])
                    {
                        result++;
                    }
                }
            }
            else
            {
                result = nums.Length;
            }
            return result;
        }

        private static int Temp(int[] nums)
        {
            if (nums.Length == 0)
                return 0;
            int j = 0;
            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i] != nums[j])
                    nums[++j] = nums[i];
            }
            return ++j;
        }
    }
}
